package com.btt.pattern.singleton.lazy;

/**
 * 饿汉式单例
 *
 * 外部需要的时候才进行实例化
 *
 * created by Btt on 2018/06/28
 */
public class LazyOne {

    private LazyOne(){}

    private static LazyOne LAZYONE = null;

    public static final LazyOne getInstance(){

        /**
         * 调用方法之前，先判断
         * 如果没有初始化，将其进行初始化，并且赋值
         * 将该实力缓存好
         */
        if(LAZYONE == null){
            LAZYONE = new LazyOne();
        }

        return LAZYONE;

    }

}
